package com.sora.sora.manager.controller;

import com.sora.sora.common.model.vo.ResultVO;
import com.sora.sora.common.utils.ResponseResult;
import com.sora.sora.manager.service.SysTagService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "标签管理", tags = "管理员进行标签管理")
@RestController
@RequestMapping("/sys/tag")
public class SysTagController {

    @Resource
    SysTagService sysTagService;

    @Resource
    ResponseResult responseResult;


    @ApiOperation(value = "陈列所有标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "limit", value = "每页取得记录条数", required = true, dataType = "int", paramType = "query")
    })
    @GetMapping
    public ResultVO listTags(@RequestParam("page") int page, @RequestParam int limit) {
        return null;
    }


    @ApiOperation(value = "得到标签总数")
    @GetMapping("/count")
    public ResultVO count() {
        return responseResult.ok(sysTagService.getCount());
    }


    @ApiOperation(value = "根据id删除标签")
    @ApiImplicitParam(name = "id", value = "需要删除的标签id", required = true, dataType = "int", paramType = "query")
    @ApiResponses({
            @ApiResponse(code = 200, message = "删除成功"),
            @ApiResponse(code = 1002, message = "删除失败")
    })
    @DeleteMapping
    public ResultVO deleteTag(int id) {
        int i = sysTagService.deleteTag(id);
        return i > 0 ? responseResult.ok() : responseResult.faile();
    }


    @ApiOperation(value = "查看标签使用详情")
    @ApiImplicitParam(name = "id", value = "需要查看详情的标签id", required = true, dataType = "int", paramType = "path")
    @GetMapping("/{id}")
    public ResultVO queryDetail(@PathVariable("id") int id) {
        return null;
    }
}
